home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / bpwmru.zip / MRUTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1993-06-04  |  4KB  |  133 lines

  1. program MRUTest;
  2. uses OWindows, WinTypes, WinProcs, OStdDlgs, OMRUList, WinDOS, Strings;
  3. {$R MRU.RES}
  4. const
  5.      CM_Quit = 108;
  6.      CM_Open = 102;
  7.  
  8. type
  9.     PWinApp = ^TWinApp;
  10.     TWinApp = object( TApplication )
  11.       procedure InitMainWindow; virtual;
  12.     end;
  13.  
  14.     PAppWin = ^TAppWin;
  15.     TAppWin = object( TWindow )
  16.       MRU : PMRUList;
  17.       Buf : array[0..fsPathName] of Char;
  18.       IniFile : array[0..fsPathName] of Char;
  19.       KeyName : array[0..31] of Char;
  20.       constructor Init( AParent: PWindowsObject; ATitle: PChar );
  21.       destructor  Done; virtual;
  22.       procedure   Quit( var Msg: TMessage ); virtual CM_First + CM_Quit;
  23.       procedure   FileOp( var Msg: TMessage ); virtual CM_First + CM_Open;
  24.       procedure   CMFile1( var Msg: TMessage ); virtual CM_First + CM_File1;
  25.       procedure   CMFile2( var Msg: TMessage ); virtual CM_First + CM_File2;
  26.       procedure   CMFile3( var Msg: TMessage ); virtual CM_First + CM_File3;
  27.       procedure   CMFile4( var Msg: TMessage ); virtual CM_First + CM_File4;
  28.       procedure   CMFile5( var Msg: TMessage ); virtual CM_First + CM_File5;
  29.       procedure   SetupWindow; virtual;
  30.     end;
  31.  
  32.     constructor TAppWin.Init;
  33.     begin
  34.          inherited Init( AParent, ATitle );
  35.          Attr.Menu := LoadMenu( HInstance, 'MRU1' );
  36.          MRU := new( PMRUList, Init(0,5,0));
  37.          StrCopy( Buf, '*.pas' );
  38.          StrCopy( IniFile, 'test.ini' );
  39.          StrCopy( KeyName, 'MyFiles' );
  40.     end;
  41.  
  42.     procedure TAppWin.SetupWindow;
  43.     begin
  44.          MRU^.LoadMRUList( Application^.MainWindow^.HWindow, IniFile, KeyName );
  45.     end;
  46.  
  47.     destructor TAppWin.Done;
  48.     begin
  49.          MRU^.SaveMRUList( IniFile, KeyName );
  50.          inherited Done;
  51.     end;
  52.  
  53.     procedure TAppWin.Quit;
  54.     begin
  55.          inherited CMExit( Msg );
  56.     end;
  57.  
  58.     procedure TAppWin.FileOp;
  59.     begin
  60.          if Application^.ExecDialog(New(PFileDialog,
  61.          Init(@Self, PChar(sd_FileOpen), Buf))) = id_OK then
  62.          begin
  63.          MRU^.AddMRUItem( HWindow, Buf );
  64.          end;
  65.     end;
  66.  
  67.     procedure TAppWin.CMFile1;
  68.     var
  69.        P : PChar;
  70.     begin
  71.          GetMem( P, 160 );
  72.          MRU^.GetMRUItem( Msg.wParam, P );
  73.          MessageBox( HWindow, P, 'GetItem', mb_ok );
  74.          MRU^.DeleteMRUItem( HWindow, P );
  75.          FreeMem( P, 160 );
  76.     end;
  77.  
  78.     procedure TAppWin.CMFile2;
  79.     var
  80.        P : PChar;
  81.     begin
  82.          GetMem( P, 160 );
  83.          MRU^.GetMRUItem( Msg.wParam, P );
  84.          MessageBox( HWindow, P, 'GetItem', mb_ok );
  85.          MRU^.DeleteMRUItem( HWindow, P );
  86.          FreeMem( P, 160 );
  87.     end;
  88.  
  89.     procedure TAppWin.CMFile3;
  90.     var
  91.        P : PChar;
  92.     begin
  93.          GetMem( P, 160 );
  94.          MRU^.GetMRUItem( Msg.wParam, P );
  95.          MessageBox( HWindow, P, 'GetItem', mb_ok );
  96.          MRU^.DeleteMRUItem( HWindow, P );
  97.          FreeMem( P, 160 );
  98.     end;
  99.  
  100.     procedure TAppWin.CMFile4;
  101.     var
  102.        P : PChar;
  103.     begin
  104.          GetMem( P, 160 );
  105.          MRU^.GetMRUItem( Msg.wParam, P );
  106.          MessageBox( HWindow, P, 'GetItem', mb_ok );
  107.          MRU^.DeleteMRUItem( HWindow, P );
  108.          FreeMem( P, 160 );
  109.     end;
  110.  
  111.     procedure TAppWin.CMFile5;
  112.     var
  113.        P : PChar;
  114.     begin
  115.          GetMem( P, 160 );
  116.          MRU^.GetMRUItem( Msg.wParam, P );
  117.          MessageBox( HWindow, P, 'GetItem', mb_ok );
  118.          MRU^.DeleteMRUItem( HWindow, P );
  119.          FreeMem( P, 160 );
  120.     end;
  121.  
  122.     procedure TWinApp.InitMainWindow;
  123.     begin
  124.          MainWindow := new( PAppWin, Init( nil, 'MRU Test' ) );
  125.     end;
  126.  
  127. var
  128.    WinApp : TWinApp;
  129. begin
  130.      WinApp.Init('WINAPP');
  131.      WinApp.Run;
  132.      WinApp.Done;
  133. end.